#ifndef SENSORSETDIALOG_H
#define SENSORSETDIALOG_H

#include <QDialog>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QMutex>
#include <QFile>










namespace Ui {
class SensorSetDialog;
}

class SensorSetDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SensorSetDialog(QWidget *parent = nullptr);
    ~SensorSetDialog();
    void initGui();
    void initData();
    void initSignal();
    void showMsgBox(QString text);
    void delayMSec(unsigned int msec);
    bool processRecvData(const uint8_t *recvBuff,int32_t recvLen,uint16_t targetAddr,uint8_t &majorFuncRecv,uint8_t &minorFuncRecv,uint8_t *dataField,uint16_t *dataFiledLen);

protected slots:
    void openSerial();



protected slots:
    void ReadUartMsg();
    void ProcessRecvMsgSlot();
    void ProcessRecvMsg(QByteArray recvBytes);



protected:
    void closeEvent(QCloseEvent *e);

private slots:
    void on_pushButton_clicked();

private:
    QTimer *m_ProMsgTimer;
    QSerialPort MySerialPort;   //串口类变量
    QByteArray m_RecvBuff;
    QMutex  m_BuffLock;

private:
    Ui::SensorSetDialog *ui;
    uint32_t m_FirmwareLenth;
    uint32_t m_RecvLength;
    QFile  m_FileFirmware;

protected slots:
    void OnSendHistoryData();
private:
    QTimer *m_SendDataTimer;
    uint16_t m_CurrentDataNo;

};

#endif // SENSORSETDIALOG_H
